home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / dskut / comt010d.zip / COMTSRC.ZIP / RAWENC.C < prev    next >
C/C++ Source or Header  |  1991-10-27  |  687b  |  33 lines

  1. #include <stdio.h>
  2. #include <io.h>
  3. #include <fcntl.h>
  4.  
  5. unsigned nencode_block(char *outblock, char *inblock, unsigned len);
  6.  
  7. #define IBSIZE (3*1024) /* must be divisible by 3 */
  8. #define OBSIZE (3*2120)
  9.  
  10. int n_inbuf;
  11. char inbuf[IBSIZE];
  12. char outbuf[OBSIZE];
  13.  
  14. unsigned int fill_inbuf(int f)
  15. {
  16.   n_inbuf=_read(f,inbuf,IBSIZE);
  17.   if(n_inbuf<0) return 0; else return n_inbuf;
  18. }
  19.  
  20. main(int argc, char **argv)
  21. {
  22.   int f;
  23.   if(argc!=2 || -1==(f=_open(argv[1],O_RDONLY|O_BINARY)))
  24.   {
  25.     fputs("RAWENC ERROR\n",stderr);
  26.     return 1;
  27.   }
  28.   nencode_block(NULL,NULL,0);
  29.   while(fill_inbuf(f))
  30.     _write(1,outbuf,nencode_block(outbuf,inbuf,n_inbuf));
  31.   _close(f);
  32. }
  33.